package com.dx.financehy.modules.user.rest;

import com.dx.financehy.annotation.rest.AnonymousGetMapping;
import com.dx.financehy.annotation.rest.AnonymousPostMapping;
import com.dx.financehy.modules.business.domain.dto.*;
import com.dx.financehy.modules.file.domain.vo.FileVO;
import com.dx.financehy.modules.file.service.FileService;
import com.dx.financehy.modules.share.domain.UserShare;
import com.dx.financehy.modules.system.domain.dto.BaseDTO;
import com.dx.financehy.modules.system.domain.dto.UpdateUserInfoDTO;
import com.dx.financehy.modules.system.domain.vo.BusinessVO;
import com.dx.financehy.modules.system.service.UserService;
import com.dx.financehy.modules.touristMessages.domain.TouristMessages;
import com.dx.financehy.modules.touristMessages.service.TouristMessagesService;
import com.dx.financehy.utils.R;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: huang_jigao
 * @Title: UserController
 * @ProjectName: financehy
 * @Description:
 * @date: 2024-05-15 14:27
 */
@Api(tags = "我的")
@RestController
@RequestMapping("/api/users")
@RequiredArgsConstructor
@Slf4j
public class UserController {

    private final UserService service;

    private final TouristMessagesService touristMessagesService;

    private final FileService fileService;

    @ApiOperation(value = "修改用户接口")
    @ApiOperationSupport(author = "itHuang")
    @PostMapping("/updateUser")
    public R<Boolean> update(@Validated @RequestBody UpdateUserInfoDTO dto) {
        return R.ok(service.updateUser(dto));
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "编辑主营业务-获取主营业务")
    @GetMapping("/getEditBusinessList")
    public R<List<BusinessVO>> getEditBusinessList() {
        return R.ok(service.getEditBusinessList());
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "新增主营业务一级业务")
    @AnonymousPostMapping("/addBusiness")
    public R addBusiness(@RequestBody @Validated AddBusinessDTO dto) {
        service.addBusiness(dto);
        return R.ok();
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "新增主营业务二级业务")
    @PostMapping("/addBusinessTwo")
    public R addBusinessTwo(@RequestBody @Validated AddBusinessTwoDTO dto) {
        service.addBusinessTwo(dto);
        return R.ok();
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "编辑主营业务一级业务")
    @PostMapping("/editBusiness")
    public R editBusiness(@RequestBody @Validated EditBusinessDTO dto) {
        service.editBusiness(dto);
        return R.ok();
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "编辑主营业务二级业务")
    @PostMapping("/editBusinessTwo")
    public R editBusinessTwo(@RequestBody @Validated EditBusinessTwoDTO dto) {
        service.editBusinessTwo(dto);
        return R.ok();
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "删除主营业务一级业务")
    @PostMapping("/delBusiness")
    public R delBusiness(@RequestBody @Validated DelBusinessDTO dto) {
        service.delBusiness(dto);
        return R.ok();
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "删除主营业务二级业务")
    @PostMapping("/delBusinessTwo")
    public R de(@RequestBody @Validated DelBusinessTwoDTO dto) {
        service.delBusinessTwo(dto);
        return R.ok();
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "查看留言")
    @GetMapping("/getTouristMessages")
    public R<List<TouristMessages>> getTouristMessages() {
        return R.ok(touristMessagesService.getTouristMessages());
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "删除留言")
    @PostMapping("/delTouristMessages")
    public R delTouristMessages(@Validated @RequestBody BaseDTO req) {
        touristMessagesService.delTouristMessages(req);
        return R.ok();
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "查看留言详情")
    @GetMapping("/getTouristMessagesDetail")
    public R<TouristMessages> getTouristMessagesDetail(@RequestParam String messagesid) {
        return R.ok(touristMessagesService.getTouristMessagesDetail(messagesid));
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "获取商家关于我们")
    @GetMapping("/getAboutUsList")
    public R<List<FileVO>> getAboutUsList(@RequestParam String userId) {
        return R.ok(fileService.selectFileByBizId(userId));
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "新增分享")
    @PostMapping("/addShare")
    public R<UserShare> addShare(@RequestBody @Validated UserShare req) {
        return R.ok(service.addShare(req));
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "新增分享")
    @AnonymousPostMapping("/getShareDetail")
    public R<UserShare> getShareDetail(@RequestBody @Validated UserShare req) {
        return R.ok(service.getShareDetail(req));
    }
}
